// Copyright (c) 2024，D-Robotics.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/***************************************************************************
 * COPYRIGHT NOTICE
 * Copyright 2019 Horizon Robotics, Inc.
 * All rights reserved.
 ***************************************************************************/
#ifndef UTILITY_SENSOR_INC_SC035HGS_SETTING_H_
#define UTILITY_SENSOR_INC_SC035HGS_SETTING_H_

#ifdef __cplusplus
extern "C" {
#endif

#define MCLK (24000000)

static uint32_t sc035hgs_linear_init_master_setting[] = {
	0x0103,  0x01,
	0x0100,  0x00,
	0x36e9,  0x80,
	0x36f9,  0x80,
	0x3000,  0x00,
	0x3001,  0x00,
	0x300f,  0x0f,
	0x3018,  0x13,
	0x3019,  0x0e,
	0x301c,  0x78,
	0x301f,  0x44,
	0x3031,  0x0a,
	0x3037,  0x20,
	0x303f,  0x01,
	0x320c,  0x06,
	0x320d,  0x40,
	0x320e,  0x04,
	0x320f,  0xe2,
	0x3217,  0x00,
	0x3218,  0x00,
	0x3220,  0x10,
	0x3223,  0x48,
	0x3226,  0x74,
	0x3227,  0x07,
	0x323b,  0x00,
	0x3250,  0xf0,
	0x3251,  0x02,
	0x3252,  0x02,
	0x3253,  0x08,
	0x3254,  0x02,
	0x3255,  0x07,
	0x3304,  0x48,
	0x3305,  0x00,
	0x3306,  0x98,
	0x3309,  0x50,
	0x330a,  0x01,
	0x330b,  0x18,
	0x330c,  0x18,
	0x330f,  0x40,
	0x3310,  0x10,
	0x3314,  0x68,
	0x3315,  0x30,
	0x3316,  0x68,
	0x3317,  0x14,
	0x3329,  0x5c,
	0x332d,  0x5c,
	0x332f,  0x60,
	0x3335,  0x64,
	0x3344,  0x64,
	0x335b,  0x80,
	0x335f,  0x80,
	0x3366,  0x06,
	0x3385,  0x41,
	0x3387,  0x49,
	0x3389,  0x01,
	0x33b1,  0x03,
	0x33b2,  0x06,
	0x33bd,  0xe0,
	0x33bf,  0x10,
	0x3621,  0xa4,
	0x3622,  0x05,
	0x3624,  0x47,
	0x3630,  0x4a,
	0x3631,  0x58,
	0x3633,  0x52,
	0x3635,  0x03,
	0x3636,  0x25,
	0x3637,  0x8a,
	0x3638,  0x0f,
	0x3639,  0x08,
	0x363a,  0x00,
	0x363b,  0x48,
	0x363c,  0x86,
	0x363e,  0xf8,
	0x3640,  0x00,
	0x3641,  0x01,
	0x36ea,  0x3b,
	0x36eb,  0x0e,
	0x36ec,  0x0e,
	0x36ed,  0x20,
	0x36fa,  0x3b,
	0x36fb,  0x10,
	0x36fc,  0x02,
	0x36fd,  0x00,
	0x3908,  0x91,
	0x391b,  0x81,
	0x3d08,  0x01,
	0x3e01,  0x18,
	0x3e02,  0xf0,
	0x3e03,  0x2b,
	0x3e06,  0x0c,
	0x3f04,  0x06,
	0x3f05,  0x20,
	0x4500,  0x59,
	0x4501,  0xc4,
	0x4603,  0x00,
	0x4800,  0x44,
	0x4809,  0x01,
	0x4810,  0x00,
	0x4811,  0x01,
	0x4837,  0x21,
	0x5011,  0x00,
	0x5988,  0x00,
	0x598e,  0x06,
	0x598f,  0x17,
	0x36e9,  0x24,
	0x36f9,  0x24,
	0x0100,  0x01,
	//delay 8ms
	DELAY_FLAG, 0x08,
	0x4418,  0x0a,
	0x363d,  0x10,
	0x4419,  0x80,
	0x0100,  0x00,
};


static uint32_t sc035hgs_linear_init_slave_setting[] = {
	0x0103,  0x01,
	0x0100,  0x00,
	0x36e9,  0x80,
	0x36f9,  0x80,
	0x3000,  0x00,
	0x3001,  0x00,
	0x300f,  0x0f,
	0x3018,  0x13,
	0x3019,  0x0e,
	0x301c,  0x78,
	0x301f,  0x44,
	0x3031,  0x0a,
	0x3037,  0x20,
	0x303f,  0x01,
	0x320c,  0x06,
	0x320d,  0x40,
	0x320e,  0x04,
	0x320f,  0xe2,
	0x3217,  0x00,
	0x3218,  0x00,
	0x3220,  0x10,
	0x3223,  0x48,
	0x3226,  0x74,
	0x3227,  0x07,
	0x323b,  0x00,
	0x3250,  0xf0,
	0x3251,  0x02,
	0x3252,  0x02,
	0x3253,  0x08,
	0x3254,  0x02,
	0x3255,  0x07,
	0x3304,  0x48,
	0x3305,  0x00,
	0x3306,  0x98,
	0x3309,  0x50,
	0x330a,  0x01,
	0x330b,  0x18,
	0x330c,  0x18,
	0x330f,  0x40,
	0x3310,  0x10,
	0x3314,  0x68,
	0x3315,  0x30,
	0x3316,  0x68,
	0x3317,  0x14,
	0x3329,  0x5c,
	0x332d,  0x5c,
	0x332f,  0x60,
	0x3335,  0x64,
	0x3344,  0x64,
	0x335b,  0x80,
	0x335f,  0x80,
	0x3366,  0x06,
	0x3385,  0x41,
	0x3387,  0x49,
	0x3389,  0x01,
	0x33b1,  0x03,
	0x33b2,  0x06,
	0x33bd,  0xe0,
	0x33bf,  0x10,
	0x3621,  0xa4,
	0x3622,  0x05,
	0x3624,  0x47,
	0x3630,  0x4a,
	0x3631,  0x58,
	0x3633,  0x52,
	0x3635,  0x03,
	0x3636,  0x25,
	0x3637,  0x8a,
	0x3638,  0x0f,
	0x3639,  0x08,
	0x363a,  0x00,
	0x363b,  0x48,
	0x363c,  0x86,
	0x363e,  0xf8,
	0x3640,  0x00,
	0x3641,  0x01,
	0x36ea,  0x3b,
	0x36eb,  0x0e,
	0x36ec,  0x0e,
	0x36ed,  0x20,
	0x36fa,  0x3b,
	0x36fb,  0x10,
	0x36fc,  0x02,
	0x36fd,  0x00,
	0x3908,  0x91,
	0x391b,  0x81,
	0x3d08,  0x01,
	0x3e01,  0x18,
	0x3e02,  0xf0,
	0x3e03,  0x2b,
	0x3e06,  0x0c,
	0x3f04,  0x06,
	0x3f05,  0x20,
	0x4500,  0x59,
	0x4501,  0xc4,
	0x4603,  0x00,
	0x4800,  0x44,
	0x4809,  0x01,
	0x4810,  0x00,
	0x4811,  0x01,
	0x4837,  0x21,
	0x5011,  0x00,
	0x5988,  0x00,
	0x598e,  0x06,
	0x598f,  0x17,
// enable trigger setting
// 035HGS single frame slave
	0x3222,  0x02,
	0x3223,  0x48,
	0x3226,  0x08,
	0x3227,  0x08,
	0x3228,  0x00,
	0x3229,  0x02,
	0x3217,  0x00,
	0x3218,  0x00,
	0x322b,  0x0b,
	0x3225,  0x04,
	0x320e,  0x3f,	// trigger mode, we will use previous vts:1250
	0x320f,  0xff,
// end trigger setting
	0x36e9,  0x24,
	0x36f9,  0x24,
	0x0100,  0x01,
	//delay 8ms
	DELAY_FLAG, 0x08,
	0x4418,  0x0a,
	0x363d,  0x10,
	0x4419,  0x80,
	0x0100,  0x00,
};

static uint32_t sc035hgs_hdr_init_setting[] = {
	0x0103,  0x01,
	0x0100,  0x00,
	0x36e9,  0x80,
	0x36f9,  0x80,
	0x3000,  0x00,
	0x3001,  0x00,
	0x300f,  0x0f,
	0x3018,  0x13,
	0x3019,  0x0e,
	0x301c,  0x78,
	0x301f,  0x44,
	0x3031,  0x0a,
	0x3037,  0x20,
	0x303f,  0x01,
	0x320c,  0x06,
	0x320d,  0x40,
	0x320e,  0x04,
	0x320f,  0xe2,
	0x3217,  0x00,
	0x3218,  0x00,
	0x3220,  0x10,
	0x3223,  0x48,
	0x3226,  0x74,
	0x3227,  0x07,
	0x323b,  0x00,
	0x3250,  0xf0,
	0x3251,  0x02,
	0x3252,  0x02,
	0x3253,  0x08,
	0x3254,  0x02,
	0x3255,  0x07,
	0x3304,  0x48,
	0x3305,  0x00,
	0x3306,  0x98,
	0x3309,  0x50,
	0x330a,  0x01,
	0x330b,  0x18,
	0x330c,  0x18,
	0x330f,  0x40,
	0x3310,  0x10,
	0x3314,  0x68,
	0x3315,  0x30,
	0x3316,  0x68,
	0x3317,  0x14,
	0x3329,  0x5c,
	0x332d,  0x5c,
	0x332f,  0x60,
	0x3335,  0x64,
	0x3344,  0x64,
	0x335b,  0x80,
	0x335f,  0x80,
	0x3366,  0x06,
	0x3385,  0x41,
	0x3387,  0x49,
	0x3389,  0x01,
	0x33b1,  0x03,
	0x33b2,  0x06,
	0x33bd,  0xe0,
	0x33bf,  0x10,
	0x3621,  0xa4,
	0x3622,  0x05,
	0x3624,  0x47,
	0x3630,  0x4a,
	0x3631,  0x58,
	0x3633,  0x52,
	0x3635,  0x03,
	0x3636,  0x25,
	0x3637,  0x8a,
	0x3638,  0x0f,
	0x3639,  0x08,
	0x363a,  0x00,
	0x363b,  0x48,
	0x363c,  0x86,
	0x363e,  0xf8,
	0x3640,  0x00,
	0x3641,  0x01,
	0x36ea,  0x3b,
	0x36eb,  0x0e,
	0x36ec,  0x0e,
	0x36ed,  0x20,
	0x36fa,  0x3b,
	0x36fb,  0x10,
	0x36fc,  0x02,
	0x36fd,  0x00,
	0x3908,  0x91,
	0x391b,  0x81,
	0x3d08,  0x01,
	0x3e01,  0x18,
	0x3e02,  0xf0,
	0x3e03,  0x2b,
	0x3e06,  0x0c,
	0x3f04,  0x06,
	0x3f05,  0x20,
	0x4500,  0x59,
	0x4501,  0xc4,
	0x4603,  0x00,
	0x4800,  0x44,
	0x4809,  0x01,
	0x4810,  0x00,
	0x4811,  0x01,
	0x4837,  0x21,
	0x5011,  0x00,
	0x5988,  0x00,
	0x598e,  0x06,
	0x598f,  0x17,
	0x36e9,  0x24,
	0x36f9,  0x24,
	0x0100,  0x01,
	//delay 8ms
	0x4418,  0x0a,
	0x363d,  0x10,
	0x4419,  0x80,
};


static uint32_t sc035hgs_again_lut0[] = {
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x0,
	0x1,
	0x1,
	0x1,
	0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
	0x90,
	0x90,
	0x98,
	0x98,
	0x98,
	0xA0,
	0xA0,
	0xA8,
	0xA8,
	0xB0,
	0xB0,
	0xB8,
	0xB8,
	0xC0,
	0xC0,
	0xC8,
	0xC8,
	0xD0,
	0xD0,
	0xD8,
	0xD8,
	0xE0,
	0xE8,
	0xE8,
	0xF0,
	0xF8,
	0xF8,
	0x80,
	0x80,
	0x88,
	0x88,
	0x88,
	0x90,
	0x90,
	0x98,
	0x98,
	0x98,
	0xA0,
	0xA0,
	0xA8,
	0xA8,
	0xB0,
	0xB0,
	0xB8,
	0xB8,
	0xC0,
	0xC0,
	0xC8,
	0xC8,
	0xD0,
	0xD0,
	0xD8,
	0xD8,
	0xE0,
	0xE8,
	0xE8,
	0xF0,
	0xF8,
	0xF8,
	0x80,
	0x80,
	0x88,
	0x88,
	0x88,
	0x90,
	0x90,
	0x98,
	0x98,
	0x98,
	0xA0,
	0xA0,
	0xA8,
	0xA8,
	0xB0,
	0xB0,
	0xB8,
	0xB8,
	0xC0,
	0xC0,
	0xC8,
	0xC8,
	0xD0,
	0xD0,
	0xD8,
	0xD8,
	0xE0,
	0xE8,
	0xE8,
	0xF0,
	0xF8,
	0xF8,
};

static uint32_t sc035hgs_stream_on_setting[] = {
	0x0100, 0x1,
};

static uint32_t sc035hgs_stream_off_setting[] = {
	0x0100, 0x0,
};

#ifdef __cplusplus
}
#endif


#endif  // UTILITY_SENSOR_INC_SC035HGS_SETTING_H_
